var approot_modlue =  approot + "/info";
var modle_name = "小说信息";

$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,4,5,6,7]}// 制定列不参与排序
		]
	});
	
});



/*添加*/
function onAdd(){
	var index = layer.open({
		type: 2,
		title: "添加" + modle_name,
		content:approot_modlue + "/add.do",
	});
	layer.full(index);
}

/*查询*/
function onQuery(){
    var select_filed = $('#select_filed').val();
    var select_text = $('#select_text').val();
 
   var query_url =approot_modlue + "/query.do?"+select_filed+"=" + select_text;

   location.href = query_url;
	
   /* layer.msg(qurey_url,{icon : 1,time : 1000,});  */
}



/*修改*/
function onEdit(id){
	var index = layer.open({
		type: 2,
		title: "修改" + modle_name,
		content: approot_modlue + "/edit.do?id=" + id,
	});
	layer.full(index);
}

/*删除*/
function onDel(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url:approot_modlue + '/del.do',
			dataType: 'text',
			data:{"id":id},
			success: function(data){
				if(data=="删除成功"){
					$(obj).parents("tr").remove();
				}
				layer.msg(data,{
					icon : 1,
					time : 1000,
				});
			},
			error:function(data) {
				layer.msg(data.responseText,{
					icon : 5,
					time : 1000,
				});
			},
		});		
	});
}


/*添加*/
function onAddChapter(obj , id){
	var index = layer.open({
		type: 2,
		title: "添加章节",
		content: approot + "/chapter/add.do?id="+id,
	});
	layer.full(index);
}


